package com.jayqqaa12.common;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;

public class ExceptionInterceptor implements Interceptor {

	@Override
	public void intercept(ActionInvocation ai) {
		String url = ai.getActionKey();

		try {
			ai.invoke();
		} catch (NullPointerException e) {
			ai.getController().renderJson("{\"code\":404,\"data\":{}}");
			e.printStackTrace();
		} catch (Exception e) {
			ai.getController().renderJson("{\"code\":500,\"data\":{}}");
			e.printStackTrace();
		}

	}

}
